


var choujiang=document.getElementById("choujiang");

var jiang2=document.getElementsByClassName("jiang2")[0];
var jiang3=document.getElementsByClassName("jiang3")[0];
var jiang1=document.getElementsByClassName("jiang1")[0];
var jiang4=document.getElementsByClassName("jiang4")[0];
var jiang8=document.getElementsByClassName("jiang8")[0];
var jiang9=document.getElementsByClassName("jiang9")[0];
var jiang5=document.getElementsByClassName("jiang5")[0];
var jiang6=document.getElementsByClassName("jiang6")[0];
var jiang11=document.getElementsByClassName("jiang11")[0];
var jiang7=document.getElementsByClassName("jiang7")[0];
var jiang12=document.getElementsByClassName("jiang12")[0];
var jiang10=document.getElementsByClassName("jiang10")[0];

var jiangzu=[jiang1,jiang2,jiang3,jiang4,jiang5,jiang6,jiang7,jiang8,jiang9,jiang10,jiang11,jiang12]
console.log(jiangzu[0])
choujiang.onclick=function (){
	i=Math.floor(Math.random()*12)
	Interval=setInterval("zhuan()", 100);
	setTimeout("ting ()",5010);
	choujiang.onclick=""
}

var i=Math.floor(Math.random()*12)
function zhuan (){
	
	jiangzu[i].style.background="pink";
	i++;
	jiangzu[i-1].style.background="#fff";
	if(i==12){
		i=0;
	}
	jiangzu[i].style.background="pink";
}
function ting (){
	clearInterval(Interval);
	alert(jiangzu[i].innerHTML);
	for(var j=0;j<jiangzu.length;j++){
		jiangzu[j].style.background="#fff";
	}
	tianjia()
	choujiang.onclick=function (){
		i=Math.floor(Math.random()*12)
		Interval=setInterval("zhuan()", 100);
		setTimeout("ting ()",5010);
		choujiang.onclick=""
	}
}
function tianjia(){
	var tr=document.createElement("tr");
	
	var td4=document.createElement("td");


	td4.innerHTML=jiangzu[i].innerHTML;

	tr.appendChild(td4);

	document.getElementById("tbody3").appendChild(tr)
}




